package com.jmp.api.controller;

import cn.hutool.core.util.ObjectUtil;
import com.jmp.base.*;
import com.jmp.api.service.SeeRecordBaseService;
import com.jmp.base.dto.*;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import one.stand.model.ResultModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cjr
 */
@Api(description = "名片查看记录")
@RestController
@Slf4j
public class SeeRecordController implements SeeRecordApi {
    @Autowired
    private SeeRecordBaseService seeRecordBaseService;

    @Override
    public ResultModel card(@RequestBody SeeRecordCardRequest request) {
        seeRecordBaseService.card(request.getUserId(), request.getCardId(), request.getItemId(), request.isWechat());
        return ResultModel.success();
    }

    @Override
    public ResultModel goodsList(@RequestBody SeeRecordGoodsListRequest request) {
        seeRecordBaseService.goodsList(request.getUserId(), request.getCardId());
        return ResultModel.success();
    }

    @Override
    public ResultModel goods(@RequestBody SeeRecordGoodsRequest request) {
        seeRecordBaseService.goods(request.getUserId(), request.getCardId(), request.getItemId(), ObjectUtil.defaultIfNull(request.getType(), 0), request.getGroupId());
        return ResultModel.success();
    }

    @Override
    public ResultModel goodsJxs(@RequestBody SeeRecordGoodsRequest request) {
        seeRecordBaseService.goodsJxs(request.getUserId(), request.getCardId(), request.getItemId());
        return ResultModel.success();
    }

    @Override
    public ResultModel goodsCount(@RequestBody SeeRecordGoodsCountRequest request) {
        seeRecordBaseService.goodsCount(request.getGoodsId());
        return ResultModel.success();
    }

    @Override
    public ResultModel article(@RequestBody SeeRecordArticleRequest request) {
        seeRecordBaseService.article(request.getUserId(), request.getCardId(), request.getItemId());
        return ResultModel.success();
    }

    @Override
    public ResultModel website(@RequestBody SeeRecordWebsiteRequest request) {
        seeRecordBaseService.website(request.getUserId(), request.getCardId(), request.getItemId());
        return ResultModel.success();
    }

    @Override
    public ResultModel lead(@RequestBody SeeRecordLeadRequest request) {
        seeRecordBaseService.lead(request.getUserId(), request.getCardId(), request.getArticleId());
        return ResultModel.success();
    }

    @Override
    public ResultModel remove(@RequestBody SeeRecordRemoveDto request) {
        seeRecordBaseService.remove(request.getUserId(), request.getCardId());
        return ResultModel.success();
    }

    @Override
    public ResultModel hide(@RequestBody SeeRecordHideDto request) {
        seeRecordBaseService.hide(request.getCardId(), request.getViewUserId());
        return ResultModel.success();
    }
}
